/**
 * 系统更新脚本
 */
import groovy.ui.SystemOutputInterceptor
import com.kdayun.manager.service.CoreVersionService
import com.kdayun.z1.core.context.Context
import com.kdayun.z1.core.message.MessageUtil
import com.kdayun.z1.core.util.FileUitls
import com.kdayun.z1.core.util.serialize.Serializer
import com.kdayun.manager.common.CoreMsgUpdate




/**
 * 脚本的入口
 * @author gk @date 2018年9月29日 下午1:54:22
 */
public void start() {
	System.out.println("平台更新脚本开始运行...");
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"平台更新脚本开始运行..."));
	CoreVersionService coreVersionService=Context.getInstance().getBean(CoreVersionService.class);
	
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"备份源文件..."));
	coreVersionService.backupSourceFiles(dir, backupRootDir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"执行更新..."));
	coreVersionService.updateDatas(dir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"处理静态资源..."));
	coreVersionService.updateStatic(dir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"处理视图资源..."));
	coreVersionService.updateView(dir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"执行脚本..."));
	coreVersionService.updateScripts(dir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"处理.class文件资源..."));
	coreVersionService.updateClassOrConifg(dir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"处理jar..."));
	
	coreVersionService.updateLib(dir);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"处理菜单资源..."));
    coreVersionService.updateMenus(dir);
	
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS,new CoreMsgUpdate(rwid,"压缩备份文件..."));
//    coreVersionService.packBackupDirFiles(backupRootDir);
	coreVersionService.handleJarVersionUpdate(dir, backupRootDir, null);
	Context.getInstance().messageService.sendMessage(MessageUtil.WM_UPDATE_PROCESS, new CoreMsgUpdate(rwid,"平台更新脚本运行结束"));
	System.out.println("平台更新脚本运行结束...");
}
start();